package com.drugStorage.struts.actions;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.drugStorage.domain.SumDrugStorageList;
import com.drugStorage.hibernate.dao.SumDrugStorageListDao;

public class ShowSumStorageAction extends DispatchAction {
	
	private SumDrugStorageListDao sumDrugStorageListDao;

	public SumDrugStorageListDao getSumDrugStorageListDao() {
		return sumDrugStorageListDao;
	}

	public void setSumDrugStorageListDao(SumDrugStorageListDao sumDrugStorageListDao) {
		this.sumDrugStorageListDao = sumDrugStorageListDao;
	}

	@Override
	protected ActionForward unspecified(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		BeanFactory factory = new ClassPathXmlApplicationContext(
		"applicationContext-*.xml");
sumDrugStorageListDao = (SumDrugStorageListDao) factory
		.getBean("sumDrugStorageListDao");

List<SumDrugStorageList> sumList= sumDrugStorageListDao.getSumDrugStorageLists();

request.setAttribute("sumList", sumList);
		return mapping.findForward("Show_SumStorageList");
	}
	
	

}
